package com.hzw.saas.service.hpc.service.impl;

import com.baomidou.mybatisplus.core.toolkit.StringUtils;
import com.baomidou.mybatisplus.extension.service.IService;
import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
import com.hzw.saas.api.hpc.IHpcConfigService;
import com.hzw.saas.api.hpc.bo.HpcConfigBo;
import com.hzw.saas.service.hpc.mapper.HpcConfigMapper;
import com.hzw.saas.service.hpc.model.HpcConfig;
import lombok.RequiredArgsConstructor;
import ma.glasnost.orika.MapperFacade;
import org.springframework.stereotype.Service;

import java.util.List;

/**
 * <p>
 * 超时中心配置表 服务实现类
 * </p>
 *
 * @author sonam
 * @since 2021-01-26
 */
@Service("hpcConfigServiceImpl")
@RequiredArgsConstructor
public class HpcConfigServiceImpl extends ServiceImpl<HpcConfigMapper, HpcConfig> implements IHpcConfigService, IService<HpcConfig> {

    private final MapperFacade mapperFacade;

    @Override
    public HpcConfigBo get(String hpcId) {
        if (StringUtils.isBlank(hpcId)) {
            return null;
        }
        HpcConfig hpcConfig = this.getById(hpcId);
        return mapperFacade.map(hpcConfig, HpcConfigBo.class);
    }

    @Override
    public List<HpcConfigBo> getAll() {
        List<HpcConfig> list = this.list();
        return mapperFacade.mapAsList(list, HpcConfigBo.class);
    }
}
